#include <time.h>
#include <stdio.h>

typedef struct REGISTER{
  unsigned char data[256/8];
}REG;

typedef REG bit_t;

typedef struct {
  bit_t b0;
  bit_t b1;
  bit_t b2;
  bit_t b3;
  bit_t b4;
  bit_t b5;
  bit_t b6;
  bit_t b7;
} bits;


void *not256(void* dest, const void* src1);
void *xor256(void* dest, const void* src1, const void* src2);
void *and256(void* dest, const void* src1, const void* src2);
void *or256(void* dest, const void* src1, const void* src2);

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

 
void s(bits in, bits *out) {
  REG * var = (REG *)calloc(256/8, 401);

  // unsigned long long int var[401];
  // for (int i = 0 ;i < 401; i++) {
  //   var[i] = &buffer[i];
  // }
  xor256( &var[8], &in.b4, &in.b0 );
  or256( &var[9], &var[8], &in.b2 );
  xor256( &var[10], &in.b6, &in.b2 );
  or256( &var[11], &var[10], &in.b0 );
  and256( &var[12], &var[11], &in.b4 );
  xor256( &var[13], &in.b1, &var[12] );
  or256( &var[14], &var[13], &in.b7 );
  xor256( &var[15], &var[9], &var[14] );
  and256( &var[16], &var[9], &in.b7 );
  or256( &var[17], &var[16], &in.b4 );
  and256( &var[18], &var[9], &var[15] );
  xor256( &var[19], &var[18], &var[10] );
  and256( &var[20], &var[19], &in.b0 );
  xor256( &var[21], &var[17], &var[20] );
  and256( &var[22], &in.b0, &var[21] );
  xor256( &var[23], &var[22], &in.b1 );
  or256( &var[24], &var[23], &in.b6 );
  xor256( &var[25], &var[21], &var[24] );
  and256( &var[26], &var[25], &in.b3 );
  xor256( &var[27], &var[15], &var[26] );
  or256( &var[28], &var[21], &var[11] );
  xor256( &var[29], &var[28], &in.b7 );
  or256( &var[30], &var[29], &in.b4 );
  xor256( &var[31], &in.b2, &var[30] );
  or256( &var[32], &var[15], &var[20] );
  xor256( &var[33], &var[32], &var[8] );
  or256( &var[34], &var[33], &in.b6 );
  xor256( &var[35], &var[31], &var[34] );
  xor256( &var[36], &var[26], &var[10] );
  and256( &var[37], &var[36], &in.b2 );
  and256( &var[38], &var[13], &in.b7 );
  xor256( &var[39], &var[37], &var[38] );
  and256( &var[40], &var[39], &in.b3 );
  xor256( &var[41], &var[35], &var[40] );
  and256( &var[42], &var[41], &in.b5 );
  xor256( &var[43], &var[27], &var[42] );
  and256( &var[44], &in.b2, &var[41] );
  xor256( &var[45], &var[44], &var[20] );
  or256( &var[46], &var[20], &in.b6 );
  and256( &var[47], &var[46], &var[9] );
  and256( &var[48], &var[47], &in.b5 );
  xor256( &var[49], &var[45], &var[48] );
  xor256( &var[50], &var[46], &var[19] );
  or256( &var[51], &var[50], &var[38] );
  xor256( &var[52], &var[38], &var[32] );
  or256( &var[53], &var[52], &var[22] );
  and256( &var[54], &var[53], &in.b5 );
  xor256( &var[55], &var[51], &var[54] );
  and256( &var[56], &var[55], &in.b4 );
  xor256( &var[57], &var[49], &var[56] );
  or256( &var[58], &var[39], &var[33] );
  xor256( &var[59], &var[58], &in.b7 );
  or256( &var[60], &var[45], &var[25] );
  xor256( &var[61], &var[60], &var[32] );
  or256( &var[62], &var[61], &in.b5 );
  xor256( &var[63], &var[59], &var[62] );
  not256( &var[64], &var[53] );
  and256( &var[65], &var[49], &in.b2 );
  xor256( &var[66], &var[64], &var[65] );
  and256( &var[67], &var[19], &var[66] );
  xor256( &var[68], &var[67], &var[24] );
  or256( &var[69], &var[68], &in.b5 );
  xor256( &var[70], &var[66], &var[69] );
  or256( &var[71], &var[70], &in.b0 );
  xor256( &var[72], &var[63], &var[71] );
  or256( &var[73], &var[72], &in.b3 );
  xor256( &var[74], &var[57], &var[73] );
  or256( &var[75], &var[74], &in.b1 );
  xor256( &out->b4, &var[43], &var[75] );
  or256( &var[77], &var[68], &in.b3 );
  xor256( &var[78], &var[77], &var[11] );
  or256( &var[79], &var[29], &in.b4 );
  xor256( &var[80], &var[79], &in.b3 );
  and256( &var[81], &var[80], &in.b0 );
  xor256( &var[82], &var[78], &var[81] );
  or256( &var[83], &var[60], &var[41] );
  xor256( &var[84], &var[83], &var[23] );
  and256( &var[85], &var[34], &var[74] );
  or256( &var[86], &var[85], &var[64] );
  and256( &var[87], &var[86], &in.b0 );
  xor256( &var[88], &var[84], &var[87] );
  and256( &var[89], &var[88], &in.b1 );
  xor256( &var[90], &var[82], &var[89] );
  xor256( &var[91], &var[21], &in.b3 );
  and256( &var[92], &var[91], &var[84] );
  xor256( &var[93], &var[29], &var[53] );
  and256( &var[94], &var[93], &var[85] );
  or256( &var[95], &var[67], &var[36] );
  xor256( &var[96], &var[95], &var[56] );
  and256( &var[97], &var[96], &in.b0 );
  xor256( &var[98], &var[94], &var[97] );
  or256( &var[99], &var[98], &in.b7 );
  xor256( &var[100], &var[92], &var[99] );
  and256( &var[101], &var[100], &in.b6 );
  xor256( &var[102], &var[90], &var[101] );
  and256( &var[103], &var[39], &var[92] );
  xor256( &var[104], &var[103], &var[86] );
  or256( &var[105], &var[74], &var[98] );
  xor256( &var[106], &var[105], &var[56] );
  and256( &var[107], &var[106], &in.b0 );
  xor256( &var[108], &var[104], &var[107] );
  xor256( &var[109], &var[106], &var[102] );
  and256( &var[110], &var[109], &var[13] );
  or256( &var[111], &var[46], &in.b7 );
  xor256( &var[112], &var[110], &var[111] );
  or256( &var[113], &var[112], &in.b2 );
  xor256( &var[114], &var[108], &var[113] );
  xor256( &var[115], &var[100], &var[34] );
  or256( &var[116], &var[115], &var[102] );
  or256( &var[117], &in.b6, &in.b2 );
  xor256( &var[118], &var[116], &var[117] );
  xor256( &var[119], &var[105], &var[33] );
  xor256( &var[120], &var[119], &var[12] );
  or256( &var[121], &var[120], &in.b7 );
  xor256( &var[122], &var[20], &var[121] );
  and256( &var[123], &var[122], &in.b4 );
  xor256( &var[124], &var[118], &var[123] );
  and256( &var[125], &var[124], &in.b3 );
  xor256( &var[126], &var[114], &var[125] );
  or256( &var[127], &var[126], &in.b5 );
  xor256( &out->b2, &var[102], &var[127] );
  or256( &var[129], &var[124], &out->b4 );
  xor256( &var[130], &var[129], &var[25] );
  or256( &var[131], &var[130], &in.b3 );
  xor256( &var[132], &var[84], &var[131] );
  xor256( &var[133], &var[115], &var[130] );
  or256( &var[134], &var[133], &var[98] );
  and256( &var[135], &var[97], &in.b6 );
  xor256( &var[136], &var[134], &var[135] );
  or256( &var[137], &var[136], &in.b4 );
  xor256( &var[138], &var[132], &var[137] );
  not256( &var[139], &in.b1 );
  xor256( &var[140], &var[92], &var[85] );
  or256( &var[141], &var[140], &var[56] );
  or256( &var[142], &var[141], &in.b2 );
  xor256( &var[143], &var[139], &var[142] );
  or256( &var[144], &var[13], &var[103] );
  xor256( &var[145], &var[144], &var[24] );
  or256( &var[146], &var[145], &in.b3 );
  xor256( &var[147], &var[12], &var[146] );
  or256( &var[148], &var[147], &in.b6 );
  xor256( &var[149], &var[143], &var[148] );
  and256( &var[150], &var[149], &in.b5 );
  xor256( &var[151], &var[138], &var[150] );
  and256( &var[152], &var[61], &var[147] );
  xor256( &var[153], &var[152], &var[115] );
  and256( &var[154], &var[150], &var[70] );
  xor256( &var[155], &var[154], &var[119] );
  and256( &var[156], &var[155], &in.b1 );
  xor256( &var[157], &var[153], &var[156] );
  xor256( &var[158], &var[56], &var[138] );
  or256( &var[159], &var[158], &var[66] );
  or256( &var[160], &in.b2, &in.b3 );
  xor256( &var[161], &var[159], &var[160] );
  and256( &var[162], &var[161], &in.b0 );
  xor256( &var[163], &var[157], &var[162] );
  xor256( &var[164], &var[15], &var[73] );
  xor256( &var[165], &var[164], &in.b6 );
  xor256( &var[166], &var[99], &var[121] );
  xor256( &var[167], &var[166], &var[115] );
  xor256( &var[168], &var[140], &var[23] );
  or256( &var[169], &var[168], &var[125] );
  and256( &var[170], &var[169], &in.b0 );
  xor256( &var[171], &var[167], &var[170] );
  and256( &var[172], &var[171], &in.b4 );
  xor256( &var[173], &var[165], &var[172] );
  or256( &var[174], &var[173], &in.b5 );
  xor256( &var[175], &var[163], &var[174] );
  or256( &var[176], &var[175], &in.b7 );
  xor256( &out->b1, &var[151], &var[176] );
  xor256( &var[178], &var[64], &var[126] );
  xor256( &var[179], &var[178], &var[127] );
  xor256( &var[180], &var[96], &var[60] );
  xor256( &var[181], &var[180], &var[150] );
  and256( &var[182], &var[181], &in.b0 );
  xor256( &var[183], &var[179], &var[182] );
  and256( &var[184], &var[69], &var[136] );
  xor256( &var[185], &var[184], &var[119] );
  and256( &var[186], &var[185], &in.b1 );
  xor256( &var[187], &var[171], &var[186] );
  and256( &var[188], &var[187], &in.b7 );
  xor256( &var[189], &var[183], &var[188] );
  and256( &var[190], &var[72], &var[116] );
  xor256( &var[191], &var[190], &var[23] );
  or256( &var[192], &var[191], &in.b7 );
  xor256( &var[193], &var[153], &var[192] );
  and256( &var[194], &var[159], &var[167] );
  xor256( &var[195], &var[194], &var[48] );
  or256( &var[196], &var[82], &var[195] );
  and256( &var[197], &var[196], &var[160] );
  and256( &var[198], &var[197], &in.b0 );
  xor256( &var[199], &var[195], &var[198] );
  or256( &var[200], &var[199], &in.b1 );
  xor256( &var[201], &var[193], &var[200] );
  or256( &var[202], &var[201], &in.b4 );
  xor256( &var[203], &var[189], &var[202] );
  xor256( &var[204], &var[70], &var[146] );
  xor256( &var[205], &var[204], &var[129] );
  or256( &var[206], &var[164], &var[23] );
  xor256( &var[207], &var[206], &var[31] );
  and256( &var[208], &var[207], &in.b0 );
  xor256( &var[209], &var[205], &var[208] );
  and256( &var[210], &out->b4, &var[190] );
  xor256( &var[211], &var[210], &var[49] );
  and256( &var[212], &var[211], &in.b5 );
  xor256( &var[213], &var[209], &var[212] );
  and256( &var[214], &var[184], &var[176] );
  xor256( &var[215], &var[214], &var[199] );
  or256( &var[216], &var[151], &var[108] );
  xor256( &var[217], &var[216], &var[93] );
  and256( &var[218], &var[217], &in.b7 );
  xor256( &var[219], &var[91], &var[218] );
  or256( &var[220], &var[219], &in.b1 );
  xor256( &var[221], &var[215], &var[220] );
  and256( &var[222], &var[221], &in.b3 );
  xor256( &var[223], &var[213], &var[222] );
  or256( &var[224], &var[223], &in.b2 );
  xor256( &out->b3, &var[203], &var[224] );
  or256( &var[226], &var[27], &var[57] );
  and256( &var[227], &var[226], &var[100] );
  xor256( &var[228], &var[43], &var[70] );
  and256( &var[229], &var[228], &var[217] );
  and256( &var[230], &var[176], &out->b4 );
  xor256( &var[231], &var[230], &var[157] );
  and256( &var[232], &var[231], &in.b0 );
  xor256( &var[233], &var[229], &var[232] );
  or256( &var[234], &var[233], &in.b4 );
  xor256( &var[235], &var[227], &var[234] );
  and256( &var[236], &var[115], &var[167] );
  or256( &var[237], &var[236], &var[151] );
  and256( &var[238], &var[237], &in.b5 );
  xor256( &var[239], &var[202], &var[238] );
  and256( &var[240], &var[9], &var[51] );
  xor256( &var[241], &var[240], &var[206] );
  or256( &var[242], &var[53], &in.b5 );
  xor256( &var[243], &var[241], &var[242] );
  and256( &var[244], &var[243], &in.b7 );
  xor256( &var[245], &var[239], &var[244] );
  or256( &var[246], &var[245], &in.b3 );
  xor256( &var[247], &var[235], &var[246] );
  and256( &var[248], &var[70], &out->b2 );
  xor256( &var[249], &var[248], &var[20] );
  and256( &var[250], &var[88], &var[173] );
  xor256( &var[251], &var[250], &var[175] );
  and256( &var[252], &var[196], &var[52] );
  xor256( &var[253], &var[252], &var[250] );
  and256( &var[254], &var[253], &in.b0 );
  xor256( &var[255], &var[251], &var[254] );
  or256( &var[256], &var[255], &in.b6 );
  xor256( &var[257], &var[249], &var[256] );
  xor256( &var[258], &var[35], &var[193] );
  xor256( &var[259], &var[258], &var[132] );
  and256( &var[260], &var[147], &in.b6 );
  xor256( &var[261], &var[259], &var[260] );
  not256( &var[262], &var[214] );
  xor256( &var[263], &var[62], &var[204] );
  or256( &var[264], &var[263], &var[260] );
  and256( &var[265], &var[264], &in.b3 );
  xor256( &var[266], &var[262], &var[265] );
  or256( &var[267], &var[266], &in.b5 );
  xor256( &var[268], &var[261], &var[267] );
  or256( &var[269], &var[268], &in.b4 );
  xor256( &var[270], &var[257], &var[269] );
  and256( &var[271], &var[270], &in.b1 );
  xor256( &out->b0, &var[247], &var[271] );
  or256( &var[273], &var[157], &var[212] );
  xor256( &var[274], &var[273], &var[226] );
  and256( &var[275], &var[98], &var[234] );
  or256( &var[276], &var[275], &var[253] );
  and256( &var[277], &var[276], &in.b0 );
  xor256( &var[278], &var[274], &var[277] );
  and256( &var[279], &var[32], &var[78] );
  xor256( &var[280], &var[279], &var[235] );
  and256( &var[281], &var[280], &in.b7 );
  xor256( &var[282], &var[278], &var[281] );
  and256( &var[283], &var[157], &var[221] );
  xor256( &var[284], &var[283], &var[44] );
  and256( &var[285], &var[86], &in.b0 );
  xor256( &var[286], &var[284], &var[285] );
  or256( &var[287], &var[27], &var[149] );
  xor256( &var[288], &var[287], &var[57] );
  and256( &var[289], &var[288], &in.b1 );
  xor256( &var[290], &var[286], &var[289] );
  and256( &var[291], &var[290], &in.b4 );
  xor256( &var[292], &var[282], &var[291] );
  or256( &var[293], &var[261], &var[217] );
  xor256( &var[294], &var[293], &var[249] );
  and256( &var[295], &var[59], &var[231] );
  xor256( &var[296], &var[295], &var[142] );
  and256( &var[297], &var[296], &in.b1 );
  xor256( &var[298], &var[294], &var[297] );
  or256( &var[299], &var[153], &var[15] );
  and256( &var[300], &var[299], &var[164] );
  and256( &var[301], &var[300], &in.b0 );
  xor256( &var[302], &var[298], &var[301] );
  and256( &var[303], &var[193], &var[66] );
  xor256( &var[304], &var[303], &var[120] );
  xor256( &var[305], &var[146], &var[190] );
  or256( &var[306], &var[305], &var[304] );
  and256( &var[307], &var[306], &in.b0 );
  xor256( &var[308], &var[304], &var[307] );
  and256( &var[309], &var[193], &var[140] );
  or256( &var[310], &var[309], &var[286] );
  and256( &var[311], &var[310], &in.b3 );
  xor256( &var[312], &var[308], &var[311] );
  and256( &var[313], &var[312], &in.b7 );
  xor256( &var[314], &var[302], &var[313] );
  and256( &var[315], &var[314], &in.b6 );
  xor256( &out->b5, &var[292], &var[315] );
  or256( &var[317], &var[26], &var[227] );
  xor256( &var[318], &var[317], &var[308] );
  or256( &var[319], &var[150], &var[138] );
  xor256( &var[320], &var[319], &var[116] );
  and256( &var[321], &var[320], &in.b0 );
  xor256( &var[322], &var[318], &var[321] );
  and256( &var[323], &out->b1, &var[91] );
  or256( &var[324], &var[323], &var[292] );
  and256( &var[325], &var[324], &in.b6 );
  xor256( &var[326], &var[322], &var[325] );
  xor256( &var[327], &var[245], &var[14] );
  or256( &var[328], &var[327], &var[219] );
  or256( &var[329], &var[268], &var[270] );
  xor256( &var[330], &var[329], &var[253] );
  and256( &var[331], &var[214], &in.b7 );
  xor256( &var[332], &var[330], &var[331] );
  or256( &var[333], &var[332], &in.b6 );
  xor256( &var[334], &var[328], &var[333] );
  and256( &var[335], &var[334], &in.b1 );
  xor256( &var[336], &var[326], &var[335] );
  or256( &var[337], &var[280], &var[203] );
  xor256( &var[338], &var[337], &var[155] );
  or256( &var[339], &var[162], &in.b2 );
  xor256( &var[340], &var[338], &var[339] );
  xor256( &var[341], &var[335], &var[207] );
  xor256( &var[342], &var[341], &var[227] );
  or256( &var[343], &var[342], &in.b0 );
  xor256( &var[344], &var[141], &var[343] );
  or256( &var[345], &var[344], &in.b6 );
  xor256( &var[346], &var[340], &var[345] );
  and256( &var[347], &var[99], &var[95] );
  xor256( &var[348], &var[347], &var[44] );
  and256( &var[349], &var[165], &in.b3 );
  xor256( &var[350], &var[348], &var[349] );
  or256( &var[351], &var[36], &var[295] );
  xor256( &var[352], &var[351], &var[178] );
  or256( &var[353], &var[352], &in.b7 );
  xor256( &var[354], &var[72], &var[353] );
  or256( &var[355], &var[354], &in.b1 );
  xor256( &var[356], &var[350], &var[355] );
  and256( &var[357], &var[356], &in.b4 );
  xor256( &var[358], &var[346], &var[357] );
  and256( &var[359], &var[358], &in.b5 );
  xor256( &out->b7, &var[336], &var[359] );
  not256( &var[361], &var[110] );
  or256( &var[362], &var[361], &in.b3 );
  xor256( &var[363], &var[323], &var[362] );
  and256( &var[364], &var[108], &var[90] );
  xor256( &var[365], &var[364], &var[248] );
  and256( &var[366], &var[365], &in.b5 );
  xor256( &var[367], &var[363], &var[366] );
  xor256( &var[368], &var[264], &var[101] );
  or256( &var[369], &var[368], &var[183] );
  and256( &var[370], &var[41], &var[207] );
  xor256( &var[371], &var[370], &var[268] );
  or256( &var[372], &var[341], &var[187] );
  xor256( &var[373], &var[372], &var[282] );
  and256( &var[374], &var[373], &in.b0 );
  xor256( &var[375], &var[371], &var[374] );
  or256( &var[376], &var[375], &in.b5 );
  xor256( &var[377], &var[369], &var[376] );
  and256( &var[378], &var[377], &in.b7 );
  xor256( &var[379], &var[367], &var[378] );
  xor256( &var[380], &var[200], &var[118] );
  or256( &var[381], &var[380], &var[105] );
  or256( &var[382], &var[169], &var[179] );
  xor256( &var[383], &var[382], &var[121] );
  or256( &var[384], &var[194], &var[83] );
  xor256( &var[385], &var[384], &var[203] );
  and256( &var[386], &var[385], &in.b0 );
  xor256( &var[387], &var[383], &var[386] );
  or256( &var[388], &var[387], &in.b5 );
  xor256( &var[389], &var[381], &var[388] );
  xor256( &var[390], &var[252], &var[352] );
  xor256( &var[391], &var[390], &var[120] );
  not256( &var[392], &var[130] );
  and256( &var[393], &var[392], &in.b5 );
  xor256( &var[394], &var[391], &var[393] );
  or256( &var[395], &var[193], &var[257] );
  xor256( &var[396], &var[395], &var[252] );
  and256( &var[397], &var[396], &in.b0 );
  xor256( &var[398], &var[394], &var[397] );
  or256( &var[399], &var[398], &in.b3 );
  xor256( &var[400], &var[389], &var[399] );
  or256( &var[401], &var[400], &in.b1 );
  xor256( &out->b6, &var[379], &var[401] );
}

unsigned char GM_SM4_SBOX[256] = {
	0xd6, 0x90, 0xe9, 0xfe, 0xcc, 0xe1, 0x3d, 0xb7, 0x16, 0xb6, 0x14, 0xc2, 0x28, 0xfb, 0x2c, 0x05,
	0x2b, 0x67, 0x9a, 0x76, 0x2a, 0xbe, 0x04, 0xc3, 0xaa, 0x44, 0x13, 0x26, 0x49, 0x86, 0x06, 0x99,
	0x9c, 0x42, 0x50, 0xf4, 0x91, 0xef, 0x98, 0x7a, 0x33, 0x54, 0x0b, 0x43, 0xed, 0xcf, 0xac, 0x62,
	0xe4, 0xb3, 0x1c, 0xa9, 0xc9, 0x08, 0xe8, 0x95, 0x80, 0xdf, 0x94, 0xfa, 0x75, 0x8f, 0x3f, 0xa6,
	0x47, 0x07, 0xa7, 0xfc, 0xf3, 0x73, 0x17, 0xba, 0x83, 0x59, 0x3c, 0x19, 0xe6, 0x85, 0x4f, 0xa8,
	0x68, 0x6b, 0x81, 0xb2, 0x71, 0x64, 0xda, 0x8b, 0xf8, 0xeb, 0x0f, 0x4b, 0x70, 0x56, 0x9d, 0x35,
	0x1e, 0x24, 0x0e, 0x5e, 0x63, 0x58, 0xd1, 0xa2, 0x25, 0x22, 0x7c, 0x3b, 0x01, 0x21, 0x78, 0x87,
	0xd4, 0x00, 0x46, 0x57, 0x9f, 0xd3, 0x27, 0x52, 0x4c, 0x36, 0x02, 0xe7, 0xa0, 0xc4, 0xc8, 0x9e,
	0xea, 0xbf, 0x8a, 0xd2, 0x40, 0xc7, 0x38, 0xb5, 0xa3, 0xf7, 0xf2, 0xce, 0xf9, 0x61, 0x15, 0xa1,
	0xe0, 0xae, 0x5d, 0xa4, 0x9b, 0x34, 0x1a, 0x55, 0xad, 0x93, 0x32, 0x30, 0xf5, 0x8c, 0xb1, 0xe3,
	0x1d, 0xf6, 0xe2, 0x2e, 0x82, 0x66, 0xca, 0x60, 0xc0, 0x29, 0x23, 0xab, 0x0d, 0x53, 0x4e, 0x6f,
	0xd5, 0xdb, 0x37, 0x45, 0xde, 0xfd, 0x8e, 0x2f, 0x03, 0xff, 0x6a, 0x72, 0x6d, 0x6c, 0x5b, 0x51,
	0x8d, 0x1b, 0xaf, 0x92, 0xbb, 0xdd, 0xbc, 0x7f, 0x11, 0xd9, 0x5c, 0x41, 0x1f, 0x10, 0x5a, 0xd8,
	0x0a, 0xc1, 0x31, 0x88, 0xa5, 0xcd, 0x7b, 0xbd, 0x2d, 0x74, 0xd0, 0x12, 0xb8, 0xe5, 0xb4, 0xb0,
	0x89, 0x69, 0x97, 0x4a, 0x0c, 0x96, 0x77, 0x7e, 0x65, 0xb9, 0xf1, 0x09, 0xc5, 0x6e, 0xc6, 0x84,
	0x18, 0xf0, 0x7d, 0xec, 0x3a, 0xdc, 0x4d, 0x20, 0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48
};



int test() {
  clock_t start, end;
  unsigned char res[1024];
  int iter = 100;
  unsigned char t[1024];

  start = clock();
  for (int ii = 0; ii < 256; ii ++) {
      t[ii] = rand() % 256;
    }
  for (int i = 0; i < iter; i++) {
    for(int j =0 ;j < 1024; j ++) {
      res[j] = GM_SM4_SBOX[t[j]];
    }
  }
  end = clock();
  double d=(double)((end-start)*1000)/CLOCKS_PER_SEC;
  printf("Test table search: %f ms\n", d);

 //---------------------------------------------------------------

  // REG * buffer = (REG *)calloc(256/8, 401);

  // unsigned long long int var[401];
  // for (int i = 0 ;i < 401; i++) {
  //   var[i] = &buffer[i];
  // }

  bits in, out;
  memcpy(&in, t, 256);


  iter = 100;
  start = clock();
  for (int i = 0; i < iter; i++) {
    s(in, &out);
  }
  end = clock();
  d = (double)(end - start)*1000/CLOCKS_PER_SEC;
  printf("Test bit slice: %f ms\n", d);

}

void main() {
  test();
}